﻿using DotNetDetour;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace KFX.DotNetDetour.Main
{
    internal class mods : IMethodHook
    {
        [HookMethod("System.IO.Directory", null, null)]
        public static string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
        {
            string[] array = GetFiles_Original(path, searchPattern, searchOption);
            bool flag = array == null;
            bool flag2 = flag;
            if (flag2)
            {
                array = new string[0];
            }
            for (int i = 0; i < array.Length; i++)
            {
                bool flag3 = !isGoodMod(array[i]);
                bool flag4 = flag3;
                if (flag4)
                {
                    array[i] = "";
                }
            }
            return array;
        }

        // Token: 0x06000039 RID: 57 RVA: 0x000029CC File Offset: 0x00000BCC
        [OriginalMethod]
        public static string[] GetFiles_Original(string path, string searchPattern, SearchOption searchOption)
        {
            return null;
        }

        // Token: 0x0600003A RID: 58 RVA: 0x000029E0 File Offset: 0x00000BE0
        [HookMethod("System.IO.Directory", null, null)]
        public static string[] GetFiles(string path)
        {
            string[] array = GetFiles_Original(path);
            bool flag = array == null;
            bool flag2 = flag;
            if (flag2)
            {
                array = new string[0];
            }
            for (int i = 0; i < array.Length; i++)
            {
                bool flag3 = !isGoodMod(array[i]);
                bool flag4 = flag3;
                if (flag4)
                {
                    array[i] = "";
                }
            }
            return array;
        }

        // Token: 0x0600003B RID: 59 RVA: 0x00002A44 File Offset: 0x00000C44
        [OriginalMethod]
        public static string[] GetFiles_Original(string path)
        {
            return null;
        }

        // Token: 0x0600003C RID: 60 RVA: 0x00002A58 File Offset: 0x00000C58
        [HookMethod("System.IO.Directory", null, null)]
        public static string[] GetFiles(string path, string searchPattern)
        {
            string[] array = GetFiles_Original(path, searchPattern);
            bool flag = array == null;
            bool flag2 = flag;
            if (flag2)
            {
                array = new string[0];
            }
            for (int i = 0; i < array.Length; i++)
            {
                bool flag3 = !isGoodMod(array[i]);
                bool flag4 = flag3;
                if (flag4)
                {
                    array[i] = "";
                }
            }
            return array;
        }

        // Token: 0x0600003D RID: 61 RVA: 0x00002AC0 File Offset: 0x00000CC0
        [OriginalMethod]
        public static string[] GetFiles_Original(string path, string searchPattern)
        {
            return null;
        }

        // Token: 0x0600003E RID: 62 RVA: 0x00002AD4 File Offset: 0x00000CD4
        public static bool isGoodMod(string filePath)
        {
            try
            {
                bool flag = filePath.Contains("\\Game\\.minecraft\\mods\\") && filePath.EndsWith(".jar") && !filePath.Contains("@");
                bool flag2 = flag;
                if (flag2)
                {
                    return false;
                }
            }
            catch
            {
                return false;
            }
            return true;
        }

        // Token: 0x0600003F RID: 63 RVA: 0x00002B38 File Offset: 0x00000D38
        [HookMethod("WPFLauncher.Manager.Auth.arq", null, null)]
        public bool get_modsChanged()
        {
            return false;
        }

        // Token: 0x06000040 RID: 64 RVA: 0x0000286C File Offset: 0x00000A6C
        [OriginalMethod]
        private static void get_modsChanged_Original()
        {
        }
    }
}
